torque.panels['torrents.files'] = new Ext.Panel({
    title:'Files',
    iconCls:'icon-files',
    autoScroll:true,
    disabled: true
});
torque.stores['torrent.files'] = new Ext.data.Store({
    id: 'TorqueTorrentFilesStore',
    autoLoad: false,
    remoteSort: false,
    proxy: new Ext.data.HttpProxy({
        url: torque.paths.root+'/api/json/peers/',
        method: 'GET'
    }),
    reader: new Ext.data.JsonReader(
        {
            root: 'files'
        },
        [
            {name: 'extension', type: 'string', mapping: 'extension'},
            {name: 'path', type: 'string', mapping: 'path'},
            {name: 'priority', type: 'int', mapping: 'priority'},
            {name: 'progress', type: 'float', mapping: 'progress'},
        ]
    ),
    listeners: {
        'beforeload': {
            fn: function(obj) {
                if(torque.torrents.activeHash != null) {
                   obj.proxy.conn.url = torque.paths.root+'/api/json/files/'+torque.torrents.activeHash;
                }                            
            }
        },
    }
});

TorqueTorrentFiles = new Ext.grid.ColumnModel([
    {header: 'Extension', dataIndex: 'extension', renderer:torque.converter.img.extension, header:false, width:30},
    {header: 'Path', dataIndex: 'path', width:600},
    {header: 'Progress', dataIndex: 'progress', renderer:torque.converter.numeric.percentage, width:200},
    {header: 'Priority', dataIndex: 'priority', width:200},
]);

torque.panels['torrents.files'] = new Ext.grid.GridPanel({
    title:'Files',
    store: torque.store('torrent.files'),
    cm: TorqueTorrentFiles,
    iconCls:'icon-files',
    bbar: torque.bar('bottom.files.bbar'),
    listeners: {
        'beforeshow': {
            fn: function(obj) {
                obj.getStore().removeAll();
                obj.getStore().reload();
            }
        }
    },
    autoScroll:true,
    disabled:true,
});